var e = require("../../api.js"),
  t = getApp();

Page({
  data: {
    page: 1,
    show_qrcode: !1,
    status: 1,
    list: {},
    list1: [],
    list2: [],
    show1: true,
    show2: false,
  },
  show_list1() {
    this.setData({
      show1: true,
      show2: false
    })
  },
  show_list2() {
    this.setData({
      show1: false,
      show2: true
    })
  },
  copy_num(e) {
    wx.setClipboardData({
      data: e.currentTarget.dataset.num,
      success(res) {
        wx.getClipboardData({
          success(res) {
            console.log(res.data) // data
          }
        });
        wx.showToast({
          title: '复制成功',
          icon: 'success',
          duration: 1500
        })
      }
    })
  },
  onLoad: function(options) {
    var _this = this;
    t.request({
      url: e.user.volume,
      data: {
        volume_goods_id: options.id
      },
      success: function(res) {
        console.log(res.data)
        if (res.code == 0) {
          function time(unixtime) {
            var dateTime = new Date(parseInt(unixtime) * 1000)
            var year = dateTime.getFullYear();
            var month = dateTime.getMonth() + 1;
            var day = dateTime.getDate();
            var timeSpanStr = year + '-' + month + '-' + day;
            return timeSpanStr;
          }
          for (var i = 0; i < res.data.list2.length;i++){
            res.data.list2[i].create_time = time(res.data.list2[i].create_time)
          }
          _this.setData({
            list: res.data.list,
            list1: res.data.list1,
            list2: res.data.list2
          })
        }

      }
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {

  }
});